package leetcode.sword;

public class P16 {

    public static void main(String[] args) {
        System.out.println(myPow(0.999900000,2147483647));
    }

//    public static double myPow(double x, int n) {  //太慢
////        long m = Math.abs((long)n);
////        double y = 1.0;
////        for(int i=0;i<m;i++){
////            y*=x;
////        }
////        if(n<0){
////            y = 1.0/y;
////        }
////        return y;
////    }
    public static double myPow(double x, int n) { //快速幂
        long m = Math.abs((long)n);
        double y = 1.0;
        while (m!=0){
            if((m&1)==1){
                y *= x;
            }
            m >>>= 1;
            x *= x;
        }
        return y;
    }
}
